﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UdrinkWater_Project.Admin
{
    public partial class InStockDetial : System.Web.UI.Page
    {
        public static string ManuDate;
        private string Connection = ConfigurationManager.ConnectionStrings["DB_Udrink"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            string Date = Session["ProductDate"].ToString();
            DataTable dtInStock = GetInList(Date);
            txtDate.Text = dtInStock.Rows[0]["Product_Date"].ToString();
            txtEmpId.Text = dtInStock.Rows[0]["Act_Officer"].ToString();
            txtEmpName.Text = dtInStock.Rows[0]["EmpName"].ToString();
            gv1.DataSource = dtInStock;
            gv1.DataBind();
        }
        private DataTable GetInList(string indate)
        {
            string sqltext = @"SELECT        TB_StockProductIN.Product_Date, TB_StockProductIN.Product_ID, TB_Product.Product_name, TB_Unit_Category.Unit_Name, TB_StockProductIN.Product_Count, TB_StockProductIN.Act_Officer, 
                         TB_Employee.Prefix + ' ' + TB_Employee.Firstname + ' ' + TB_Employee.Lastname AS EmpName,'เข้าคลัง' AS Status
                         FROM            TB_Product LEFT JOIN
                         TB_Unit_Category ON TB_Product.Unit = TB_Unit_Category.Unit_ID LEFT JOIN
                         TB_StockProductIN LEFT JOIN
                         TB_Employee ON TB_StockProductIN.Act_Officer = TB_Employee.ID_Card ON TB_Product.Product_ID = TB_StockProductIN.Product_ID
                         WHERE TB_StockProductIN.Product_Date ='"+indate+"' ";
            SqlConnection sqlconn = new SqlConnection(Connection);
            SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
            DataSet ds = new DataSet();
            da.Fill(ds);
            return ds.Tables[0];
        }
    }
}